<?php

namespace App\Http\Requests\Logic\User;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class UpdateResource extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
		return [
			'name' => 'required',
			'mobile' => [
				'required',
				'regex:/^(1[3|4|5|6|7|8|9])\d{9}$/',
				Rule::unique('users')->ignore($this->user)
			],
			'birthday' => 'nullable',
			'gender' => 'nullable',
			'identification' => [
				'required',
				Rule::unique('users')->ignore($this->user)
			],
			'company_id' => 'nullable',
			'project_id' => 'nullable',
			'position_id' => 'nullable',
			'avatar' => 'nullable',
			'certificate' => 'nullable',
			'manager' => 'boolean',
			'stature' => 'nullable',
			'education' => 'nullable',
			'address' => 'nullable',
			'marital' => 'nullable',
			'urgency' => 'nullable',
			'trade' => 'nullable',
			'skill' => 'nullable',
			'channel' => 'nullable',
			'debit' => 'nullable',
		];
    }

	/**
	 * 定义错误响应消息
	 *
	 * Date: 12/04/2018
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'name.required' => '请输入姓名',
			'mobile.required' => '请输入手机号码',
			'mobile.regex' => '您输入的手机号码有误',
			'mobile.unique' => '您输入的手机号码已存在',
			'identification.required' => '请输入身份证号',
			'manager.boolean' => '管理者选项的值只能为真或假'
		];
	}
}
